<template>
  <cs-config-provider :size="getGlobalComponentSize">
    <router-view />
  </cs-config-provider>
</template>

<script setup lang="ts">
  import { computed, nextTick, onBeforeMount, onMounted } from 'vue'
  import { useTagsViewRoutes } from '/@/stores/tags-view-routes'
  import other from '/@/utils/other'
  import { Session } from '/@/utils/storage'
  import setIntroduction from './utils/set-iconfont'
  import type { EpPropMergeType } from 'element-plus/es/utils'

  defineOptions({ name: 'App' })

  const stores = useTagsViewRoutes()
  // 获取全局组件大小
  const getGlobalComponentSize = computed(() => {
    return other.globalComponentSize() as EpPropMergeType<
      StringConstructor,
      '' | 'default' | 'small' | 'large',
      never
    >
  })

  // 设置初始化，防止刷新时恢复默认
  onBeforeMount(() => {
    // 设置批量第三方 icon 图标
    setIntroduction.cssCdn()
    // 设置批量第三方 js
    setIntroduction.jsCdn()
  })
  // 页面加载时
  onMounted(() => {
    nextTick(() => {
      // 获取缓存中的全屏配置
      if (Session.get('isTagsViewCurrenFull')) {
        stores.setCurrenFullscreen(Session.get('isTagsViewCurrenFull'))
      }
    })
  })
</script>
